package com.limf.demo.java8;

import java.util.Objects;
import java.util.function.Predicate;

public class PredicateTest {

	public static void main(String[] args) {
		test();
	}
	
	static void test() {
		Predicate<String> predicate = (s)->s.length()>0;
		System.out.println(predicate.test("foo"));     // true;
		System.out.println(predicate.negate().test("foo"));  // false;
		Predicate<Boolean> nonNull = Objects::nonNull;
		System.out.println(nonNull.test(false));    // true
		Predicate<Boolean> isNull = Objects::isNull;
		System.out.println(isNull.test(true));   // false
		
		Predicate<String> isEmpty = String::isEmpty;
		System.out.println(isEmpty.test(""));    // true
		
		Predicate<String> isNotEmpty = isEmpty.negate();
		System.out.println(isNotEmpty.test("abc"));   // true
		
	}
	
}
